import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { environment } from '@env/environment';
// layout
import { LayoutDefaultComponent } from '../layout/default/default.component';
import { LayoutFullScreenComponent } from '../layout/fullscreen/fullscreen.component';
import { LayoutPassportComponent } from '../layout/passport/passport.component';
// dashboard pages
import { DashboardComponent } from './dashboard/dashboard.component';
// allendpoint pages
import { AllEndpointComponent } from './endpointmanager/allendpoint/allendpoint.component';
// allpayment pages
import { AllPaymentComponent } from './paymentmanager/allpayment/allpayment.component';
// allpayment pages
import { AllAppComponent } from './thirdpartyappmanager/allapp/allapp.component';
// allaccount pages
import { AllaccountComponent } from './accountmanager/allaccount/allaccount.component';
// allservice pages
import { AllservicelogComponent } from './servicelogmanager/allservicelog/allservicelog.component';
// passport pages
import { UserLoginComponent } from './passport/login/login.component';
import { UserRegisterComponent } from './passport/register/register.component';
import { UserRegisterResultComponent } from './passport/register-result/register-result.component';
// single pages
import { CallbackComponent } from './callback/callback.component';
import { UserLockComponent } from './passport/lock/lock.component';
import { Exception403Component } from './exception/403.component';
import { Exception404Component } from './exception/404.component';
import { Exception500Component } from './exception/500.component';

const routes: Routes = [
  {
    path: '', redirectTo: '/passport/login', pathMatch: 'full',
  },
  {
    path: 'main',
    component: LayoutDefaultComponent,
    children: [
      { path: '', redirectTo: 'accountmanager/allaccount', pathMatch: 'full' },
      { path: 'dashboard', component: DashboardComponent, data: { title: '仪表盘'} },
      {
        path: 'accountmanager',
        children: [
          { path: 'allaccount', component: AllaccountComponent, data: { title: '所有账号'} },
        ]
      },
      {
        path: 'servicelogmanager',
        children: [
          { path: 'allservicelog', component: AllservicelogComponent, data: { title: '所有日志' } },
        ]
      },
      {
        path: 'endpointmanager',
        children: [
          { path: 'allendpoint', component: AllEndpointComponent, data: { title: '所有节点'} },
        ]
      },
      {
        path: 'paymentmanager',
        children: [
          { path: 'allpayment', component: AllPaymentComponent, data: { title: '所有支付方式'} },
        ]
      },
      {
        path: 'thirdpartyappmanager',
        children: [
          { path: 'allapp', component: AllAppComponent, data: { title: '所有App'} },
        ]
      }
    ]
  },
  {
    path: 'passport',
    component: LayoutPassportComponent,
    children: [
      { path: '', redirectTo: 'login', pathMatch: 'full' },
      { path: 'login', component: UserLoginComponent, data: { title: '登录'} },
      // { path: 'register', component: UserRegisterComponent, data: { title: '注册', titleI18n: 'pro-register' } },
      // { path: 'register-result', component: UserRegisterResultComponent, data: { title: '注册结果', titleI18n: 'pro-register-result' } }
    ]
  },
  // // 单页不包裹Layout
  // { path: 'callback/:type', component: CallbackComponent },
  { path: 'lock', component: UserLockComponent, data: { title: '锁屏', titleI18n: 'lock' } },
  // { path: '403', component: Exception403Component },
  { path: '404', component: Exception404Component },
  // { path: '500', component: Exception500Component },
  // { path: '**', redirectTo: 'dashboard' }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: environment.useHash })],
  exports: [RouterModule]
})
export class RouteRoutingModule { }
